package com.example.mapper;

import com.example.dto.Category;
import com.example.dto.Goods;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <P> @Author: SongKeCheng
 * <P> Description:
 * <P> Type: Interface
 * <P> Date: 2024/6/20:15:10
 */

public interface GoodsMapper {

    public List<Goods> allGoods();


    //以id查询
    public Goods findById(Integer id);


    //以id、author查询
    public Goods findByIdAndAuthor(Map<String, Object> map);
    //     where id =#{id}
    //              and author =#{author}

    /**
     * 方法入参多参数接收
     */
    public Goods findByIdAndAuthorMuti(@Param("id") Integer id,
                                       @Param("author") String author);

    /**
     * 方法入参多参数接收
     */
    public Goods findByIdAndAuthorObj(@Param("goods") Goods goods);


    //添加商品
    public Integer addGoods(Goods goods);

    //删除商品
    public Integer deleteGoods(Integer id);

    /**
     * 动态sql 标签 if
     */
    public List<Goods> findByDyIf(Goods goods);

    /**
     * 动态sql 标签 where 自动加上 where 关键字 和 去掉多余的 and 关键字
     */
    public List<Goods> findByDyWhere(Goods goods);


    /**
     * 动态sql 标签 choose 同 java的 switch case
     */
    public List<Goods> findByNameOrAuthor(Goods goods);


    /**
     * 动态sql 标签 foreach
     */
    public List<Goods> selectGoodsSByIds(@Param("ids") List<Integer> ids);


    public Category findCategory(Integer id);


}
